<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function back(){
		var customerId = "<c:out value='${customerId}'/>";
		var sign = "<c:out value='${sign}'/>";
		window.location.href = "./customerManage.do?action=customerDetail&customerId="+customerId+"&sign="+sign;
		window.location.target = "main";
	}
	
	function viewCustomer(id){
		document.customerUpdateHistoryForm.action = "./customerManage.do?action=customerUpdateHistoryDetail&id="+id;
		document.customerUpdateHistoryForm.target = "cHistoryFrame";
		document.customerUpdateHistoryForm.submit();
	}
	
	function restoreCustomer(){
		var customerId = "<c:out value='${customerId}'/>";
		var sign = "<c:out value='${sign}'/>";
		var ids = document.getElementsByName("id");
		var flag = 0;
		for(var i = 0; i < ids.length; i++){
			if(ids[i].checked)flag = flag + 1;
		}
		if(flag > 0){
			document.customerUpdateHistoryForm.action = "./customerManage.do?action=restoreCustomerInfo&customerId="+customerId+"&sign="+sign;
			document.customerUpdateHistoryForm.target = "main";
			document.customerUpdateHistoryForm.submit();
		}else{
			alert("<fmt:message key='common.message.wRestore'/>");
		}
	}
	
	function initPage(){
		if("<c:out value='${result}'/>" == 1){
			alert("<fmt:message key='common.message.restoreSuccess'/>");
		}
	}
	
-->
</script>
</head>
<body onload="initPage()">
<form name="customerUpdateHistoryForm" action="" method="post">
	<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
						<td class="title_lab">
							<fmt:message key='customer.title.customerHistory'/>
						</td>
					</tr>
					<tr>
						<td align="center" valign="bottom">
							<c:if test="${isRestoreCustomer == 1}">
							<button class="btn_submit" onclick="restoreCustomer()" hidefocus="true"><fmt:message key='common.button.restore'/></button>&nbsp;&nbsp;
							</c:if>
							<button class="btn_back" onclick="back()" hidefocus="true">取消并返回</button>
						</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td class="title_lab">
							<fmt:message key='customer.title.customerHistory'/>
						</td>
					</tr>
					<tr>
						<td>
							<table class="table">
								<tr>
									<td valign="top">
										<table class="table_style">
											<tr>
												<td class="title" width="8"></td>
												<td class="title" width="30"><fmt:message key='common.lable.checkbox'/></td>
												<td class="title" width="10%"><fmt:message key='customer.lable.updateRecord'/></td>
												<td class="title" width="30">共享</td>
												<td class="title" width="30">状态</td>
												<td class="title"><fmt:message key='customer.lable.customerName'/></td>
												<td class="title" width="8%"><fmt:message key='customer.lable.linkmanNum'/></td>
												<td class="title" width="12%"><fmt:message key='customer.lable.lastlink'/></td>
												<td class="title" width="10%"><fmt:message key='customer.lable.updatePerson'/></td>
												<td class="title" width="12%"><fmt:message key='customer.lable.updateDate'/></td>
											</tr>
											<%int i = 1; %>
											<c:forEach var="customer" items="${customers}">
											<tr onmouseover="onmousemoveChange(this,'img${customer.id}')" onmouseout="onmouseoutChange(this,'img${customer.id}')">
												<td height="16" width="8" align="right"><img id="img${customer.id}" src="./images/table_sign2.bmp"></td>
												<td><input id="id" name="id" type="radio" value="${customer.id}"/></td>
												<c:choose>
													<c:when test="${customer.isPrimitive == 1}">
														<td style="color: red;"><fmt:message key='customer.lable.primitive'/></td>
													</c:when>
													<c:otherwise>
														<td><fmt:message key='customer.lable.updateRecord'/><%=i%><%i ++;%></td>
													</c:otherwise>
												</c:choose>
												<td align="center">
													<c:if test="${customer.isShare == 1}">
													<img class="btn_img" src="./images/share.gif" onclick="" title="<fmt:message key='customer.lable.share'/>">
													</c:if>
												</td>
												<td align="center">
													<c:if test="${customer.isFollow == 1}">
													<img class="btn_img" src="./images/follow.gif" onclick="" title="<fmt:message key='customer.lable.follow'/>">&nbsp;&nbsp;
													</c:if>
												</td>
												<td align="left"><a href="javascript:viewCustomer(${customer.id});">${customer.customerName}</a></td>
												<td>${customer.linkmanNum}</td>
												<td><fmt:formatDate value="${customer.lastLink}" pattern="yyyy-MM-dd"/></td>
												<td>${customer.updatePerson}</td>
												<td><fmt:formatDate value="${customer.updateDate}" pattern="yyyy-MM-dd"/></td>
											</tr>
											</c:forEach>
										</table>
									</td>
								</tr>
								<tr>
									<td>
										<!-- page -->
										<table class="table_page">
											<tr>
												<td class="a_tools">
													${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>&nbsp;&nbsp;
													<fmt:message key='common.page.totalPage'/>&nbsp;${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;&nbsp;
													<fmt:message key='common.page.current'/>&nbsp;${currentPage}&nbsp;<fmt:message key='common.page'/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													<a href="./customerManage.do?action=customerUpdateHistory&flag=1&customerId=${customerId}&sign=${sign}" target="main" hidefocus="true"><fmt:message key='common.page.first'/></a>&nbsp;&nbsp;
													<a href="./customerManage.do?action=customerUpdateHistory&flag=2&customerId=${customerId}&sign=${sign}" target="main" hidefocus="true"><fmt:message key='common.page.previous'/></a>&nbsp;&nbsp;
													<a href="./customerManage.do?action=customerUpdateHistory&flag=3&customerId=${customerId}&sign=${sign}" target="main" hidefocus="true"><fmt:message key='common.page.next'/></a>&nbsp;&nbsp;
													<a href="./customerManage.do?action=customerUpdateHistory&flag=4&customerId=${customerId}&sign=${sign}" target="main" hidefocus="true"><fmt:message key='common.page.last'/></a>
												</td>
											</tr>
										</table>
									</td>
								</tr>
								<tr>
									<td class="" valign="top" style="padding: 0 0 0 0;">
										<iframe src="" id="cHistoryFrame" name="cHistoryFrame" frameborder="0" scrolling="no" width="100%" 
											onload="this.height=cHistoryFrame.document.body.scrollHeight"></iframe>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>
</body> 
</html>